<template>
  <div class="dashboard">
    <div>
      <!-- 扫码区域 -->
      <div id="qr-code-reader" ref="qrCodeReader"></div>
      <!-- 显示扫描结果 -->
      <p v-if="scanResult">扫描结果：{{ scanResult }}</p>
      <!-- 控制按钮 -->
      <button @click="stopScan">停止扫描</button>
    </div>
  </div>
</template>

<script setup lang="ts">
import { useScan } from '@/hooks/useScan';

const { scanResult, stopScan, qrCodeReader } = useScan();
</script>

<style lang="scss" scoped>
.dashboard {
  padding: 20px;

  &-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;

    h2 {
      margin: 0;
      font-size: 24px;
      color: var(--theme-text-color);
    }

    .dashboard-actions {
      display: flex;
      gap: 10px;
    }
  }

  &-stats {
    margin-bottom: 20px;

    .stat-card {
      height: 100px;

      .stat-content {
        display: flex;
        align-items: center;
        height: 100%;
      }

      .stat-icon {
        width: 60px;
        height: 60px;
        border-radius: 50%;
        display: flex;
        align-items: center;
        justify-content: center;
        margin-right: 15px;

        .el-icon {
          font-size: 24px;
          color: #fff;
        }
      }

      .stat-info {
        .stat-title {
          font-size: 14px;
          color: var(--theme-text-color);
          margin-bottom: 5px;
        }

        .stat-value {
          font-size: 24px;
          font-weight: bold;
          color: var(--theme-text-color);
        }
      }
    }
  }

  &-content {
    .app-list {
      .card-header {
        display: flex;
        justify-content: space-between;
        align-items: center;
      }
    }
  }
}
</style>
